#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "prescheme.h"

void string_copyB(char*, long, char*, long, long);
char *string_append(char*, char*);
char demo_string_append(char*, char*, FILE *);
long main(long, char**);


void string_copyB(char *target_0X, long offset_1X, char *source_2X, long start_3X, long end_4X)
{
  long arg0K1;
  long arg0K0;
  long src_6X;
  long tgt_5X;
 {  arg0K0 = offset_1X;
  arg0K1 = start_3X;
  goto L18;}
 L18: {
  tgt_5X = arg0K0;
  src_6X = arg0K1;
  if ((src_6X == end_4X)) {
    return;}
  else {
    *(target_0X + tgt_5X) = (*(source_2X + src_6X));
    arg0K0 = (1 + tgt_5X);
    arg0K1 = (1 + src_6X);
    goto L18;}}
}
char *string_append(char *a_7X, char *b_8X)
{
  char *target_11X;
  long len_b_10X;
  long len_a_9X;
 {  len_a_9X = strlen((char *) a_7X);
  len_b_10X = strlen((char *) b_8X);
  target_11X = (char *)calloc( 1, 1 + (len_a_9X + len_b_10X));string_copyB(target_11X, 0, a_7X, 0, len_a_9X);string_copyB(target_11X, len_a_9X, b_8X, 0, len_b_10X);
  return target_11X;}
}
char demo_string_append(char *a_12X, char *b_13X, FILE * out_14X)
{
  char *str_15X;
 {  str_15X = string_append(a_12X, b_13X);
  ps_write_string(str_15X, out_14X);
  { long ignoreXX;
  PS_WRITE_CHAR(10, out_14X, ignoreXX) }
  free(str_15X);
  return 1;}
}
long main(long argc_16X, char **argv_17X)
{
  FILE * out_21X;
  char *b_20X;
  char *a_19X;
  FILE * out_18X;
 {  if ((3 == argc_16X)) {
    out_18X = stdout;
    a_19X = *(argv_17X + 1);
    b_20X = *(argv_17X + 2);demo_string_append(a_19X, a_19X, out_18X);demo_string_append(a_19X, b_20X, out_18X);demo_string_append(b_20X, b_20X, out_18X);
    return 0;}
  else {
    out_21X = stderr;
    ps_write_string("Usage: ", out_21X);
    ps_write_string((*(argv_17X + 0)), out_21X);
    ps_write_string(" <string-a> <string-b>", out_21X);
    { long ignoreXX;
    PS_WRITE_CHAR(10, out_21X, ignoreXX) }
    ps_write_string("  Prints permutations of <string-a> and <string-b>.", out_21X);
    { long ignoreXX;
    PS_WRITE_CHAR(10, out_21X, ignoreXX) }
    return 1;}}
}
